#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>

int main(){
  printf("testexec ... begin\n");
  pid_t id = fork();
  if(id==0){
    sleep(2);
    //child
    char *const argv[]={
      (char*)"ls",  
      (char*)"-a",
      (char*)"-l",
      (char*)"--color",
      NULL
    };
    execvp("ls",argv);
    exit(1);
  }
  //father
  int status = 0;
  pid_t rid = waitpid(id,&status,0);
  if(rid>0){
    printf("father wait success,child exit code:%d\n",WEXITSTATUS(status));
  }
  printf("testexec ... end!\n");
  return 0;
}
